package com.lwlean.test.utils;

import com.google.gson.*;

import java.lang.reflect.Type;

public class IntegerDeserializer implements JsonDeserializer<Integer>{

	
	 @Override
	 public Integer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)throws JsonParseException {
		  try {
			  if (json.getAsString().equals("") || json.getAsString().equals("null")) {
				  return null;
			  }
		  } catch (Exception ignore) {
		  }
		  try {
			  return json.getAsInt();
		  } catch (NumberFormatException e) {
			  throw new JsonSyntaxException(e);
		  }
	 }
}
